package cn.whb.hrm.controller;

import cn.whb.hrm.dto.SmsCodeDto;
import cn.whb.hrm.service.IVerifyService;
import cn.whb.hrm.util.AjaxResult;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyController {
    @Autowired
    private IVerifyService verifyService;

    /**
     * 生成验证码
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{key}")
    public AjaxResult imageCode(@PathVariable("key") String key){
        return verifyService.imageCode(key);
    }

    /**
     * 发送手机验证码
     * @param dto
     * @return
     */
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody @Valid SmsCodeDto dto){
        return verifyService.sendSmsCode(dto);
    }
}
